-
Notifications
You must be signed in to change notification settings - Fork 13.4k
HIR ty lowering: Clean up & refactor the lowering of type-relative paths #140218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0100118
to
3d66b7b
Compare
This comment was marked as resolved.
This comment was marked as resolved.
3d66b7b
to
c9df43c
Compare
This comment was marked as resolved.
This comment was marked as resolved.
…e of TyCtxt They are not the same.
Name them more consistently, descriptively and appropriately. Move large error reporting methods into the dedicated error module to make the happy paths in HIR ty lowering more legible.
IMPORTANT: This leads to a tiny diagnostic regression that will be fixed in the next commit!
Most notably, this preserves the `(..)` of ambiguous RTN paths.
c9df43c
to
8c37c8c
Compare
compiler-errors
approved these changes
May 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!! sorry for the review delay, and thanks for the careful refactoring.
r=me after rebase just for good measure
actually whatever, bors will figure out if it needs a rebase lol @bors r+ |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 22, 2025
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#135562 (Add ignore value suggestion in closure body) - rust-lang#139635 (Finalize repeat expr inference behaviour with inferred repeat counts) - rust-lang#139668 (Handle regions equivalent to 'static in non_local_bounds) - rust-lang#140218 (HIR ty lowering: Clean up & refactor the lowering of type-relative paths) - rust-lang#140435 (use uX::from instead of _ as uX in non - const contexts) - rust-lang#141130 (rustc_on_unimplemented cleanups) - rust-lang#141286 (Querify `coroutine_hidden_types`) Failed merges: - rust-lang#140247 (Don't build `ParamEnv` and do trait solving in `ItemCtxt`s when lowering IATs) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 23, 2025
Rollup merge of rust-lang#140218 - fmease:hirtylo-clean-up-path-low, r=compiler-errors HIR ty lowering: Clean up & refactor the lowering of type-relative paths While rebasing rust-lang#126651 I realized that HIR ty lowering could benefit from some *spring cleaning* now that it's been extended to handle RTN and mGCA paths. More seriously, similar to my merged PR rust-lang#118668 which unified the handling of all *associated item constraints* (assoc ty, const (ACE) & fn (RTN)), this PR (commit rust-lang@695fcf5) partially[^1] deduplicates the resolution code for all *type-relative paths* (assoc ty, const (mGCA) & fn (RTN)). **Why**? DRY'ing that part of the code means PR rust-lang#126651 will automatically support RTN paths like `Ty::AssocTy::assoc_fn(..)` and it also implies shared diagnostic code and thus better diagnostics for RTN. --- The other commits represent cleanups, renamings, moves. More notably, I've renamed path lowering methods to be a lot more descriptive, so ones lowering `QPath(Resolved)` paths now have `_resolved_` in their name and ones lowering `QPath(TypeRelative)` paths now have `_type_relative_` in their name. This should make it stupidly obvious what their purpose is. --- Best reviewed commit by commit. The changes are close to trivial but the diff might make it look hairier. r? compiler-errors [^1]: Sadly, I couldn't unify as much compared to the other PR without introducing unnecessary `unreachable!()`s or rendering the code otherwise illegible with flags and micro helper traits.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While rebasing #126651 I realized that HIR ty lowering could benefit from some spring cleaning now that it's been extended to handle RTN and mGCA paths.
More seriously, similar to my merged PR #118668 which unified the handling of all associated item constraints (assoc ty, const (ACE) & fn (RTN)), this PR (commit 695fcf5) partially1 deduplicates the resolution code for all type-relative paths (assoc ty, const (mGCA) & fn (RTN)).
Why? DRY'ing that part of the code means PR #126651 will automatically support RTN paths like
Ty::AssocTy::assoc_fn(..)
and it also implies shared diagnostic code and thus better diagnostics for RTN.The other commits represent cleanups, renamings, moves. More notably, I've renamed path lowering methods to be a lot more descriptive, so ones lowering
QPath(Resolved)
paths now have_resolved_
in their name and ones loweringQPath(TypeRelative)
paths now have_type_relative_
in their name. This should make it stupidly obvious what their purpose is.Best reviewed commit by commit. The changes are close to trivial but the diff might make it look hairier.
r? compiler-errors
Footnotes
Sadly, I couldn't unify as much compared to the other PR without introducing unnecessary
unreachable!()
s or rendering the code otherwise illegible with flags and micro helper traits. ↩